Processing math: 100%

single_step_integrator Derived Type

type, public, extends(ode_integrator) :: single_step_integrator

The most basic, single-step integrator object capable of integrating systems of ODE's.


Type-Bound Procedures

procedure, public :: append_to_buffer => oi_append_to_buffer

Appends the supplied solution point to the internal solution buffer.

  • private subroutine oi_append_to_buffer(this, x, y, err)

    Appends the supplied solution point to the internal solution buffer.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(inout) :: this

    The ode_integrator object.

    real(kind=real64), intent(in) :: x

    The independent variable value.

    real(kind=real64), intent(in), dimension(:) :: y

    The values of the dependent variables corresponding to x.

    class(errors), intent(inout), optional, target :: err

    An optional errors-based object that if provided can be used to retrieve information relating to any errors encountered during execution. If not provided, a default implementation of the errors class is used internally to provide error handling. Possible errors and warning messages that may be encountered are as follows.

    • DIFFEQ_MEMORY_ALLOCATION_ERROR: Occurs if there is a memory allocation issue.

procedure(attempt_single_step), public, deferred, pass :: attempt_step

Attempts an integration step for a single-step integrator.

  • subroutine attempt_single_step(this, sys, h, x, y, f, yn, fn, yerr, k) Prototype

    Attempts an integration step for a single-step integrator.

    Arguments

    Type IntentOptional Attributes Name
    class(single_step_integrator), intent(inout) :: this

    The single_step_integrator object.

    class(ode_container), intent(inout) :: sys

    The ode_container object containing the ODE's to integrate.

    real(kind=real64), intent(in) :: h

    The current step size.

    real(kind=real64), intent(in) :: x

    The current value of the independent variable.

    real(kind=real64), intent(in), dimension(:) :: y

    An N-element array containing the current solution at x.

    real(kind=real64), intent(in), dimension(:) :: f

    An N-element array containing the values of the derivatives at x.

    real(kind=real64), intent(out), dimension(:) :: yn

    An N-element array where this routine will write the next solution estimate at x + h.

    real(kind=real64), intent(out), dimension(:) :: fn

    An N-element array where this routine will write the next derivative estimate at x + h.

    real(kind=real64), intent(out), dimension(:) :: yerr

    An N-element array where this routine will write an estimate of the error in each equation.

    real(kind=real64), intent(out), dimension(:,:) :: k

    An N-by-NSTAGES matrix containing the derivatives at each stage.

procedure, public :: clear_buffer => oi_clear_buffer

Clears the contents of the buffer.

  • private subroutine oi_clear_buffer(this)

    Clears the contents of the buffer.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(inout) :: this

    The ode_integrator object.

procedure, public :: compute_error_norm => oi_estimate_error

Computes the norm of the scaled error estimate.

  • private pure function oi_estimate_error(this, y, yest, yerr) result(rst)

    Computes the norm of the scaled error estimate. A value less than one indicates a successful step. A value greater than one suggests that the results do not meet the requested tolerances.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(in) :: this

    The ode_integrator object.

    real(kind=real64), intent(in), dimension(:) :: y

    The previously accepted solution array (N-element).

    real(kind=real64), intent(in), dimension(size(y)) :: yest

    An N-element array containing the next solution point estimate.

    real(kind=real64), intent(in), dimension(size(y)) :: yerr

    An N-element array containing the estimate of error for each equation.

    Return Value real(kind=real64)

    The norm of the scaled error.

procedure, public :: estimate_inital_step_size => oi_initial_step

Computes an estimate of an initial step size.

  • private pure subroutine oi_initial_step(this, sys, xo, xf, yo, fo, h)

    Computes an estimate of an initial step size.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(in) :: this

    The ode_integrator object.

    class(ode_container), intent(in) :: sys

    The ode_container object containing the ODE's to integrate.

    real(kind=real64), intent(in) :: xo

    The initial value of the independent variable.

    real(kind=real64), intent(in) :: xf

    The final value of the independent variable.

    real(kind=real64), intent(in), dimension(:) :: yo

    The initial values of the dependent variables (N-element).

    real(kind=real64), intent(out), dimension(size(yo)) :: fo

    An N-element array where the function values at xo will be written.

    real(kind=real64), intent(out) :: h

    The initial step size estimate.

procedure, public :: estimate_next_step_size => oi_next_step

Estimates the next step size.

  • private function oi_next_step(this, e, eold, h, x, err) result(rst)

    Estimates the next step size based upon the current and previous error estimates.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(inout) :: this

    The ode_integrator object.

    real(kind=real64), intent(in) :: e

    The norm of the current scaled error estimate.

    real(kind=real64), intent(inout) :: eold

    The norm of the previous step's scaled error estimate. On output, this variable is updated.

    real(kind=real64), intent(in) :: h

    The current step size.

    real(kind=real64), intent(in) :: x

    The current independent variable value.

    class(errors), intent(inout), optional, target :: err

    An optional errors-based object that if provided can be used to retrieve information relating to any errors encountered during execution. If not provided, a default implementation of the errors class is used internally to provide error handling. Possible errors and warning messages that may be encountered are as follows.

    • DIFFEQ_STEP_SIZE_TOO_SMALL_ERROR: Occurs if the step size becomes too small in magnitude.

    Return Value real(kind=real64)

    The new step size estimate.

procedure, public :: get_absolute_tolerance => oi_get_abs_tol

Gets the absolute error tolerance.

  • private pure function oi_get_abs_tol(this) result(rst)

    Gets the absolute error tolerance.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(in) :: this

    The ode_integrator object.

    Return Value real(kind=real64)

    The tolerance value.

procedure, public :: get_allow_overshoot => oi_get_allow_overshoot

Gets a value determining if the solver is allowed to overshoot the final value in the integration range.

  • private pure function oi_get_allow_overshoot(this) result(rst)

    Gets a value determining if the solver is allowed to overshoot the final value in the integration range.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(in) :: this

    The ode_integrator object.

    Return Value logical

    True if the solver can overshoot, and then interpolate to achieve the required final value; else, false thereby indicating the solver cannot overshoot.

procedure(get_single_step_logical_parameter), public, deferred, pass :: get_is_fsal

Gets a logical parameter stating if this is a first-same-as-last (FSAL) integrator.

  • pure function get_single_step_logical_parameter(this) result(rst) Prototype

    Returns a logical parameter from a single_step_integrator object.

    Arguments

    Type IntentOptional Attributes Name
    class(single_step_integrator), intent(in) :: this

    The single_step_integrator object.

    Return Value logical

    The parameter.

procedure, public :: get_maximum_step_size => oi_get_max_step

Gets the magnitude of the maximum allowed step size.

  • private pure function oi_get_max_step(this) result(rst)

    Gets the magnitude of the maximum allowed step size.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(in) :: this

    The ode_integrator object.

    Return Value real(kind=real64)

    The step size limit.

procedure, public :: get_minimum_step_size => oi_get_min_step

Gets the magnitude of the minimum allowed step size.

  • private pure function oi_get_min_step(this) result(rst)

    Gets the magnitude of the minimum allowed step size.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(in) :: this

    The ode_integrator object.

    Return Value real(kind=real64)

    The step size limit.

procedure(ode_integer_inquiry), public, deferred, pass :: get_order

Returns the order of the integrator.

  • pure function ode_integer_inquiry(this) result(rst) Prototype

    Returns an integer value from the ode_integrator object.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(in) :: this

    The ode_integrator object.

    Return Value integer(kind=int32)

    The requested value.

procedure, public :: get_relative_tolerance => oi_get_abs_tol

Gets the relative error tolerance.

  • private pure function oi_get_abs_tol(this) result(rst)

    Gets the absolute error tolerance.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(in) :: this

    The ode_integrator object.

    Return Value real(kind=real64)

    The tolerance value.

procedure, public :: get_solution => oi_get_solution

Returns the solution computed by the integrator.

  • private pure function oi_get_solution(this) result(rst)

    Returns the solution computed by the integrator stored as a matrix with the first column containing the values of the independent variable at which the solution was computed. The remaining columns contain the solutions for each of the integrated equations in the order in which they appear in the source routine. Notice, the solve routine must be called before this routine.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(in) :: this

    The ode_integrator object.

    Return Value real(kind=real64), allocatable, dimension(:,:)

    The resulting solution matrix.

procedure(single_step_integer_inquiry), public, deferred, pass :: get_stage_count

Gets the number of stages used by the integrator.

  • pure function single_step_integer_inquiry(this) result(rst) Prototype

    Gets an integer from the integrator.

    Arguments

    Type IntentOptional Attributes Name
    class(single_step_integrator), intent(in) :: this

    The single_step_integrator object.

    Return Value integer(kind=int32)

    The integer value.

procedure, public :: get_step_limit => oi_get_step_limit

Gets the limit on the number of integration steps.

  • private pure function oi_get_step_limit(this) result(rst)

    Gets the limit on the number of integration steps that may be taken before the solver terminates.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(in) :: this

    The ode_integrator object.

    Return Value integer(kind=int32)

    The step limit.

procedure, public :: get_step_size_control_parameter => oi_get_control_parameter

Gets the step size PI control parameter.

  • private pure function oi_get_control_parameter(this) result(rst)

    Gets the step size control parameter β used for PI control of the step size. A value of 0 provides a default step size controller (non-PI); however, a nonzero value of β provides PI control that improves stability, but comes with a potential for efficiency loss. A good estimate for a starting point for this parameter is β=0.4k where k is the order of the integrator.

    The PI controller for step size is defined as follows. hn+1=fshneαneβn1

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(in) :: this

    The ode_integrator object.

    Return Value real(kind=real64)

    The control parameter.

procedure, public :: get_step_size_factor => oi_get_safety_factor

Gets the step size safety factor.

  • private pure function oi_get_safety_factor(this) result(rst)

    Gets the safety factor (step size multiplier) used to provide a measure of control to the step size estimate such that hnew=fsh, where fs is this safety factor.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(in) :: this

    The ode_integrator object.

    Return Value real(kind=real64)

    The safety factor.

procedure(single_step_interpolate), public, deferred, pass :: interpolate

Performs an interpolation to estimate the solution at the requested point.

  • subroutine single_step_interpolate(this, x, xn, yn, fn, xn1, yn1, fn1, y) Prototype

    Provides a routine for interpolation.

    Arguments

    Type IntentOptional Attributes Name
    class(single_step_integrator), intent(in) :: this

    The single_step_integrator object.

    real(kind=real64), intent(in) :: x

    The value of the independent variable at which to compute the interpolation.

    real(kind=real64), intent(in) :: xn

    The previous value of the independent variable at which the solution is computed.

    real(kind=real64), intent(in), dimension(:) :: yn

    An N-element array containing the solution at xn.

    real(kind=real64), intent(in), dimension(:) :: fn

    An N-element array containing the derivatives at xn.

    real(kind=real64), intent(in) :: xn1

    The value of the independent variable at xn + h.

    real(kind=real64), intent(in), dimension(:) :: yn1

    An N-element array containing the solution at xn + h.

    real(kind=real64), intent(in), dimension(:) :: fn1

    An N-element array containing the derivatives at xn + h.

    real(kind=real64), intent(out), dimension(:) :: y

    An N-element array where this routine will write the solution values interpolated at x.

procedure(single_step_post_step_routine), public, deferred, pass :: post_step_action

Performs actions such as setting up interpolation after completion of a successful integration step.

  • subroutine single_step_post_step_routine(this, sys, dense, x, xn, y, yn, f, fn, k) Prototype

    Provides a routine for performing any actions, such as setting up interpolation, after successful completion of a step.

    Arguments

    Type IntentOptional Attributes Name
    class(single_step_integrator), intent(inout) :: this

    The single_step_integrator object.

    class(ode_container), intent(inout) :: sys

    The ode_container object containing the ODE's to integrate.

    logical, intent(in) :: dense

    Determines if dense output is requested (true); else, false.

    real(kind=real64), intent(in) :: x

    The previous value of the independent variable.

    real(kind=real64), intent(in) :: xn

    The current value of the independent variable.

    real(kind=real64), intent(in), dimension(:) :: y

    An N-element array containing the solution at x.

    real(kind=real64), intent(in), dimension(:) :: yn

    An N-element array containing the solution at xn.

    real(kind=real64), intent(in), dimension(:) :: f

    An N-element array containing the derivatives at x.

    real(kind=real64), intent(in), dimension(:) :: fn

    An N-element array containing the derivatives at xn.

    real(kind=real64), intent(inout), dimension(:,:) :: k

    An N-by-NSTAGES matrix containing the derivatives at each stage.

procedure(single_step_pre_step_routine), public, deferred, pass :: pre_step_action

Provides a routine for performing any actions, such as setting up Jacobian calculations.

  • subroutine single_step_pre_step_routine(this, prevs, sys, h, x, y, f, err) Prototype

    Provides a routine for performing any actions, such as setting up Jacobian calculations.

    Arguments

    Type IntentOptional Attributes Name
    class(single_step_integrator), intent(inout) :: this

    The single_step_integrator object.

    logical, intent(in) :: prevs

    Defines the status of the previous step. The value is true if the previous step was successful; else, false if the previous step failed.

    class(ode_container), intent(inout) :: sys

    The ode_container object containing the ODE's to integrate.

    real(kind=real64), intent(in) :: h

    The current step size.

    real(kind=real64), intent(in) :: x

    The current value of the independent variable.

    real(kind=real64), intent(in), dimension(:) :: y

    An N-element array containing the current solution at x.

    real(kind=real64), intent(in), dimension(:) :: f

    An N-element array containing the values of the derivatives at x.

    class(errors), intent(inout), optional, target :: err

    An optional errors-based object that if provided can be used to retrieve information relating to any errors encountered during execution. If not provided, a default implementation of the errors class is used internally to provide error handling.

procedure, public :: set_absolute_tolerance => oi_set_abs_tol

Sets the absolute error tolerance.

  • private subroutine oi_set_abs_tol(this, x)

    Sets the absolute error tolerance.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(inout) :: this

    The ode_integrator object.

    real(kind=real64), intent(in) :: x

    The tolerance value.

procedure, public :: set_allow_overshoot => oi_set_allow_overshoot

Sets a value determining if the solver is allowed to overshoot the final value in the integration range.

  • private subroutine oi_set_allow_overshoot(this, x)

    Sets a value determining if the solver is allowed to overshoot the final value in the integration range.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(inout) :: this

    The ode_integrator object.

    logical, intent(in) :: x

    True if the solver can overshoot, and then interpolate to achieve the required final value; else, false thereby indicating the solver cannot overshoot.

procedure, public :: set_maximum_step_size => oi_set_max_step

Sets the magnitude of the maximum allowed step size.

  • private subroutine oi_set_max_step(this, x)

    Sets the magnitude of the maximum allowed step size.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(inout) :: this

    The ode_integrator object.

    real(kind=real64), intent(in) :: x

    The step size limit.

procedure, public :: set_minimum_step_size => oi_set_min_step

Sets the magnitude of the minimum allowed step size.

  • private subroutine oi_set_min_step(this, x)

    Sets the magnitude of the minimum allowed step size.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(inout) :: this

    The ode_integrator object.

    real(kind=real64), intent(in) :: x

    The step size limit.

procedure, public :: set_relative_tolerance => oi_set_abs_tol

Sets the relative error tolerance.

  • private subroutine oi_set_abs_tol(this, x)

    Sets the absolute error tolerance.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(inout) :: this

    The ode_integrator object.

    real(kind=real64), intent(in) :: x

    The tolerance value.

procedure, public :: set_step_limit => oi_set_step_limit

Sets the limit on the number of integration steps.

  • private subroutine oi_set_step_limit(this, x)

    Sets the limit on the number of integration steps that may be taken before the solver terminates.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(inout) :: this

    The ode_integrator object.

    integer(kind=int32), intent(in) :: x

    The step limit.

procedure, public :: set_step_size_control_parameter => oi_set_control_parameter

Sets the step size PI control parameter.

  • private subroutine oi_set_control_parameter(this, x)

    Sets the step size control parameter β used for PI control of the step size. A value of 0 provides a default step size controller (non-PI); however, a nonzero value of β provides PI control that improves stability, but comes with a potential for efficiency loss. A good estimate for a starting point for this parameter is β=0.4k where k is the order of the integrator.

    The PI controller for step size is defined as follows. hn+1=fshneαneβn1

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(inout) :: this

    The ode_integrator object.

    real(kind=real64), intent(in) :: x

    The control parameter

procedure, public :: set_step_size_factor => oi_set_safety_factor

Sets the step size safety factor.

  • private subroutine oi_set_safety_factor(this, x)

    Sets the safety factor (step size multiplier) used to provide a measure of control to the step size estimate such that hnew=fsh, where fs is this safety factor.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(inout) :: this

    The ode_integrator object.

    real(kind=real64), intent(in) :: x

    The safety factor.

procedure, public :: solve => ssi_ode_solver

Solves the supplied system of ODE's.

  • private subroutine ssi_ode_solver(this, sys, x, iv, err)

    Solves the supplied system of ODE's.

    Arguments

    Type IntentOptional Attributes Name
    class(single_step_integrator), intent(inout) :: this

    The single_step_integrator object.

    class(ode_container), intent(inout) :: sys

    The ode_container object containing the ODE's to integrate.

    real(kind=real64), intent(in), dimension(:) :: x

    An array of independent variable values at which to return the the solution to the ODE's.

    real(kind=real64), intent(in), dimension(:) :: iv

    An array containing the initial values for each ODE.

    class(errors), intent(inout), optional, target :: err

    An optional errors-based object that if provided can be used to retrieve information relating to any errors encountered during execution. If not provided, a default implementation of the errors class is used internally to provide error handling. Possible errors and warning messages that may be encountered are as follows.

    • DIFFEQ_MEMORY_ALLOCATION_ERROR: Occurs if there is a memory allocation issue.

    • DIFFEQ_NULL_POINTER_ERROR: Occurs if no ODE function is defined.

    • DIFFEQ_ARRAY_SIZE_ERROR: Occurs if there are less than 2 values given in the independent variable array x.